package cn.dapeng.designPatterns.prototype;

import lombok.Data;

import java.io.Serializable;

@Data
public class Student implements Cloneable, Serializable {

    private int age;

    private String name;

    private Address address;

    @Override
    public Student clone() {
        try {
            //浅克隆
//            return (Student) super.clone();
            // 深克隆
            Student student = (Student) super.clone();
            student.setAddress(this.getAddress().clone());
            return student;
        } catch (CloneNotSupportedException e) {
            throw new RuntimeException(e);
        }
    }

}
